﻿@model SportsStore.Web.Models.ProductListViewModel

@{
    ViewBag.Title = "Products";
}
<h1>Products:</h1>


@*@foreach (var p in Model.Products)
{
    @Html.Partial("ProductSummary", p)
}*@


<table class="table">
    <tr>
        <th>
            @Html.ActionLink("Product Id", "List", new { categoryName = Model.CurrentCategory, sortHeader = "Product_Id", sortDirection = Model.SortingPagingInfo.SortField == "Product_Id" && Model.SortingPagingInfo.SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending })
        </th>
        <th>
            @Html.ActionLink("Product Name", "List", new { categoryName = Model.CurrentCategory, sortHeader = "Product_Name", sortDirection = Model.SortingPagingInfo.SortField == "Product_Name" && Model.SortingPagingInfo.SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending })
        </th>
        <th>
            @Html.ActionLink("More Info", "List", new { categoryName = Model.CurrentCategory, sortHeader = "Product_Description", sortDirection = Model.SortingPagingInfo.SortField == "Product_Description" && Model.SortingPagingInfo.SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending })
        </th>
        <th>
            @Html.ActionLink("Category", "List", new { categoryName = Model.CurrentCategory, sortHeader = "CategoryLookup_Name", sortDirection = Model.SortingPagingInfo.SortField == "CategoryLookup_Name" && Model.SortingPagingInfo.SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending })
        </th>
        <th>
            @Html.ActionLink("Price", "List", new { categoryName = Model.CurrentCategory, sortHeader = "Product_Price", sortDirection = Model.SortingPagingInfo.SortField == "Product_Price" && Model.SortingPagingInfo.SortDirection == SortDirection.Descending ? SortDirection.Ascending : SortDirection.Descending })
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model.Products)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Product_Id)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product_Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product_Description)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CategoryLookup_Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Product_Price)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Product_Id }) |
                @Html.ActionLink("Details", "Details", new { id = item.Product_Id }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Product_Id })
            </td>
        </tr>
    }

</table>



<div class="pager">
    @Html.PageLinks(Model.SortingPagingInfo, x => Url.Action("List", new { page = x, categoryName = Model.CurrentCategory, sortHeader = Model.SortingPagingInfo.SortField, sortDirection = Model.SortingPagingInfo.SortDirection }))
</div>
